package com.haochen.generation.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.haochen.generation.domain.Leveling;
import com.haochen.generation.service.LevelingService;
import com.haochen.generation.domain.AjaxResult;
import com.haochen.generation.domain.page.TableDataInfo;

/**
 * 留言Controller
 *
 * @author 成序猿
 * @date 2023-04-01
 */
@RestController
@RequestMapping("/leveling")
public class LevelingController extends BaseController
{
    @Autowired
    private LevelingService levelingService;

    /**
     * 查询留言列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Leveling leveling)
    {
        startPage();
        List<Leveling> list = levelingService.selectLevelingList(leveling);
        return getDataTable(list);
    }

    /**
     * 获取留言详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(levelingService.selectLevelingById(id));
    }

    /**
     * 新增留言
     */
    @PostMapping
    public AjaxResult add(@RequestBody Leveling leveling)
    {
        return toAjax(levelingService.insertLeveling(leveling));
    }

    /**
     * 修改留言
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Leveling leveling)
    {
        return toAjax(levelingService.updateLeveling(leveling));
    }

    /**
     * 删除留言
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(levelingService.deleteLevelingByIds(ids));
    }
}
